#ifndef DATA_REFLOW_EVENT_SUBSCRIBER_H
#define DATA_REFLOW_EVENT_SUBSCRIBER_H

#include "rclcpp/rclcpp.hpp"
#include "data_reflow_interfaces/msg/get_event.hpp"
#include "data_reflow/data_buffer.h"
#include "data_reflow/sensor_type.h"
#include "data_reflow_interfaces/msg/sensor_data.hpp" // 确保包含消息定义

namespace data_reflow
{
    class EventSubscriber : public rclcpp::Node
    {
    public:
        EventSubscriber();

    private:
        void event_callback(const data_reflow_interfaces::msg::GetEvent::SharedPtr msg);
        void handle_collision_event(const builtin_interfaces::msg::Time &event_stamp);

        // 添加摄像头数据回调函数声明
        void camera_data_callback(const data_reflow_interfaces::msg::SensorData::SharedPtr msg);

        // 订阅者成员（事件+摄像头数据）
        rclcpp::Subscription<data_reflow_interfaces::msg::GetEvent>::SharedPtr event_sub_;
        rclcpp::Subscription<data_reflow_interfaces::msg::SensorData>::SharedPtr camera_sub_; // 新增

        // event_subscriber.h 中 EventSubscriber 类的 private 部分
        uint32_t camera_receive_count_ = 0;        // 统计订阅端收到的摄像头帧数
        rclcpp::TimerBase::SharedPtr count_timer_; // 定时打印计数

        rclcpp::Time event_time_;                  // 存储碰撞事件时间
        rclcpp::Time start_time_;                  // 存储查询开始时间
        rclcpp::Time end_time_;                    // 存储查询结束时间
        rclcpp::TimerBase::SharedPtr query_timer_; // 延迟查询的定时器
    };
} // namespace data_reflow

#endif // DATA_REFLOW_EVENT_SUBSCRIBER_H